//
// Created by ASUS on 2024/3/29.
//

#include <bits/stdc++.h>

using namespace std;

struct Node {
	Node*son[2]{};
};

Node* root = new Node();
//插入数x
void insert(int x){
	auto cur=root;
	for(int i=30;~i;--i){
		int b=x>>i&1;
		if(!cur->son[b]){
			cur->son[b]=new Node();
		}
		cur=cur->son[b];
	}
}
//查找最大异或值
int search(int x) {
	auto cur=root;
	int ans = 0;
	for (int i = 30; ~i; --i) {
		int b = x >> i & 1;
		if (cur->son[b ^ 1]) {
			ans |= 1 << i;
			cur = cur->son[b ^ 1];
		} else {
			cur = cur->son[b];
		}
	}
	return ans;
}
